<?xml version="1.0" encoding="UTF-8" ?>    							
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"   			
	"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >   						
<mapper namespace="com.cdl.dao.EmployeeMapper" >  						
		  <!-- 查询数据字段 -->															
		  <sql id="selectSql">													
		  	   select  																
			   		  ID id	
			   		, EMP_NAME empName	
			   		, JOB job	
			   		, BIRTHDAY birthday	
			   		, MGR mgr	
			   		, HIREDATA hiredata	
			   		, SALARY salary	
			   		, DEPTON depton	
			   		, CREATE_DATA createData	
			   		, UPDATE_DATE updateDate	
			   from EMPLOYEE													
		</sql>																		  

		  <!-- 主键作为唯一条件查询 -->														
		  <sql id="whereSqlByKey">												
		  	 <where> 																
				and	ID = #{id}			
		     </where> 																
		  </sql>																  

		  <!-- 多条件组合查询 -->															
		  <sql id="whereSql">														
		  	 <where> 																
		  	   <if test="id   != null   and id !=''"> and ID = #{id} </if>   
		  	   <if test="empName   != null   and empName !=''"> and EMP_NAME = #{empName} </if>   
		  	   <if test="job   != null   and job !=''"> and JOB = #{job} </if>   
		  	   <if test="birthday   != null   and birthday !=''"> and BIRTHDAY = #{birthday} </if>   
		  	   <if test="mgr   != null   and mgr !=''"> and MGR = #{mgr} </if>   
		  	   <if test="hiredata   != null   and hiredata !=''"> and HIREDATA = #{hiredata} </if>   
		  	   <if test="salary   != null   and salary !=''"> and SALARY = #{salary} </if>   
		  	   <if test="depton   != null   and depton !=''"> and DEPTON = #{depton} </if>   
		  	   <if test="createData   != null   and createData !=''"> and CREATE_DATA = #{createData} </if>   
		  	   <if test="updateDate   != null   and updateDate !=''"> and UPDATE_DATE = #{updateDate} </if>   
		     </where> 																
		  </sql>   																  

		  <!-- 获取列表 -->																
		  <select id="getList" parameterType="Employee" resultType="Employee">	
			   <include refid="selectSql"></include>								
			   <include refid="whereSql"></include>								
		  </select>																  

		  <!-- 获取单条信息 -->															
		  <select id="get" parameterType="Employee" resultType="Employee">		
			   <include refid="selectSql"></include>								
			   <include refid="whereSqlByKey"></include>							
		  </select>																  

		  <!-- 新增 -->																
		  <insert id="add" parameterType="Employee">						
		       insert into EMPLOYEE(											
		       <trim prefix="" prefixOverrides=",">								
		       	  <if test="id != null">,ID</if>   
		       	  <if test="empName != null">,EMP_NAME</if>   
		       	  <if test="job != null">,JOB</if>   
		       	  <if test="birthday != null">,BIRTHDAY</if>   
		       	  <if test="mgr != null">,MGR</if>   
		       	  <if test="hiredata != null">,HIREDATA</if>   
		       	  <if test="salary != null">,SALARY</if>   
		       	  <if test="depton != null">,DEPTON</if>   
		       	  <if test="createData != null">,CREATE_DATA</if>   
		       	  <if test="updateDate != null">,UPDATE_DATE</if>   
		       </trim>																
		       )values(																
		       <trim prefix="" prefixOverrides=",">								
		       	  <if test="id != null">,#{id}</if>   
		       	  <if test="empName != null">,#{empName}</if>   
		       	  <if test="job != null">,#{job}</if>   
		       	  <if test="birthday != null">,#{birthday}</if>   
		       	  <if test="mgr != null">,#{mgr}</if>   
		       	  <if test="hiredata != null">,#{hiredata}</if>   
		       	  <if test="salary != null">,#{salary}</if>   
		       	  <if test="depton != null">,#{depton}</if>   
		       	  <if test="createData != null">,#{createData}</if>   
		       	  <if test="updateDate != null">,#{updateDate}</if>   
		       </trim>																
		       )																	
		  </insert> 															  

		  <!-- 修改 -->																
		  <update id="update" parameterType="Employee">					
		      update EMPLOYEE													
		      <set>																	
		      	 ID   =  #{id,jdbcType=NUMERIC},   
		      	 EMP_NAME   =  #{empName,jdbcType=NVARCHAR},   
		      	 JOB   =  #{job,jdbcType=NVARCHAR},   
		      	 BIRTHDAY   =  #{birthday,jdbcType=DATE},   
		      	 MGR   =  #{mgr,jdbcType=NUMERIC},   
		      	 HIREDATA   =  #{hiredata,jdbcType=DATE},   
		      	 SALARY   =  #{salary,jdbcType=NUMERIC},   
		      	 DEPTON   =  #{depton,jdbcType=NUMERIC},   
		      	 CREATE_DATA   =  #{createData,jdbcType=DATE},   
		      	 UPDATE_DATE   =  #{updateDate,jdbcType=DATE},   
		      </set>																
		      <include refid="whereSqlByKey"></include>							
		  </update>  															  

		  <!-- 删除 -->																
		  <delete id="delete" parameterType="Employee">					
		      delete from EMPLOYEE 											
		      <include refid="whereSqlByKey"></include>							
		  </delete>																  

</mapper>    																	

